package com.k.util.excel;

import org.apache.poi.ss.usermodel.ShapeTypes;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;

public class POIXSSFUtil extends POIUtil{
    public static void drawLine(XSSFSheet sheet,
                                int drawAreaWidth, int drawAreaHeight,
                                int col1, int row1, int col2, int row2,
                                int startWidthPercentage, int startHeightPercentage, int endWidthPercentage, int endHeightPercentage) {
        int width = drawAreaWidth * 300;
        int height = drawAreaHeight * 700;
        XSSFDrawing xssfDrawing = sheet.createDrawingPatriarch();
        XSSFClientAnchor anchor = new XSSFClientAnchor(
                (width * startWidthPercentage) / 100, (height * startHeightPercentage) / 100,
                (width * endWidthPercentage) / 100, (height * endHeightPercentage) / 100,
                (short) col1, row1,
                (short) col2, row2);
        XSSFSimpleShape shape = xssfDrawing.createSimpleShape(anchor);
        shape.setShapeType(ShapeTypes.LINE);
        shape.setLineWidth(0.5);
        shape.setLineStyle(0);
        shape.setLineStyleColor(0, 0, 0);
    }
}
